Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document callable as possible #9779

Merged
merged 1 commit into from
May 23, 2022
Merged

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented May 23, 2022

Custom string functions can either be a class string or a callable
returning the function.

/**
* @return FunctionNode
*/
public function CustomFunctionsReturningStrings()
{
// getCustomStringFunction is case-insensitive
$functionName = $this->lexer->lookahead['value'];
$functionClass = $this->em->getConfiguration()->getCustomStringFunction($functionName);
assert($functionClass !== null);
$function = is_string($functionClass)
? new $functionClass($functionName)
: call_user_func($functionClass, $functionName);
$function->parse($this);
return $function;
}

As a follow up, I will make this more precise in 2.13.x (using class-string<FunctionNode>, and describing the callable more precisely.

@greg0ire greg0ire force-pushed the fix-config-phpdoc branch from e139e22 to 1455c9f Compare May 23, 2022 07:24
@greg0ire greg0ire marked this pull request as ready for review May 23, 2022 07:25
@derrabus
Copy link
Member

I think, the doc block of addCustomStringFunction() can be made more precise as well (class-string instead of just string).

@greg0ire
Copy link
Member Author

@derrabus you're correct, and that's what I'm alluding to here:

I will make this more precise in 2.13.x

@greg0ire greg0ire force-pushed the fix-config-phpdoc branch from d5c1fdd to 11c812f Compare May 23, 2022 08:38
@derrabus derrabus added this to the 2.12.3 milestone May 23, 2022
derrabus
derrabus previously approved these changes May 23, 2022
@derrabus
Copy link
Member

PHPStan baseline needs an update.

derrabus
derrabus previously approved these changes May 23, 2022
Custom string functions can either be a class string or a callable
returning the function.
@greg0ire greg0ire force-pushed the fix-config-phpdoc branch from 16c3f7f to a0697c9 Compare May 23, 2022 09:05
@greg0ire greg0ire enabled auto-merge May 23, 2022 09:06
@greg0ire greg0ire requested a review from derrabus May 23, 2022 09:06
@greg0ire greg0ire merged commit 359dd4e into doctrine:2.12.x May 23, 2022
@greg0ire greg0ire deleted the fix-config-phpdoc branch May 23, 2022 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants